diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-04 22:52:48 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-04 22:52:48 -0700 |
commit | ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c (patch) | |
tree | f340326272e72074611f8ca0dfdd315988da2886 | |
parent | 8deea28b78299717494e1d0840059321fd23590a (diff) | |
download | stage-ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c.tar.gz stage-ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c.tar.bz2 stage-ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c.tar.xz stage-ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c.zip |
Added --builtins command line option.
-rw-r--r-- | src/game.h | 7 | ||||
-rw-r--r-- | src/options.cpp | 22 | ||||
-rw-r--r-- | src/options.h | 1 |
3 files changed, 26 insertions, 4 deletions
@@ -16,18 +16,21 @@ public: | |||
16 | Game(); | 16 | Game(); |
17 | virtual ~Game(); | 17 | virtual ~Game(); |
18 | 18 | ||
19 | typedef Bu::Hash<Bu::String, Function *> FunctionHash; | ||
20 | typedef Bu::Hash<Bu::String, Situation *> SituationHash; | ||
21 | |||
19 | Function *getFunction( const Bu::String &sName ); | 22 | Function *getFunction( const Bu::String &sName ); |
20 | Variable getParam( const Bu::String &sName ) const; | 23 | Variable getParam( const Bu::String &sName ) const; |
21 | Situation *getSituation( const Bu::String &sName ); | 24 | Situation *getSituation( const Bu::String &sName ); |
22 | 25 | ||
26 | const FunctionHash &getFunctionHash() const { return hFunction; } | ||
27 | |||
23 | bool execCommand( class GameState &gState, const Bu::StringList &lCmd ); | 28 | bool execCommand( class GameState &gState, const Bu::StringList &lCmd ); |
24 | 29 | ||
25 | private: | 30 | private: |
26 | void addFunction( Function *pFunc ); | 31 | void addFunction( Function *pFunc ); |
27 | 32 | ||
28 | private: | 33 | private: |
29 | typedef Bu::Hash<Bu::String, Function *> FunctionHash; | ||
30 | typedef Bu::Hash<Bu::String, Situation *> SituationHash; | ||
31 | VariableHash hGlobalParam; | 34 | VariableHash hGlobalParam; |
32 | FunctionHash hFunction; | 35 | FunctionHash hFunction; |
33 | SituationHash hSituation; | 36 | SituationHash hSituation; |
diff --git a/src/options.cpp b/src/options.cpp index 42f58a2..23a98a8 100644 --- a/src/options.cpp +++ b/src/options.cpp | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "options.h" | 1 | #include "options.h" |
2 | #include "version.h" | 2 | #include "version.h" |
3 | #include "game.h" | ||
3 | 4 | ||
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | 6 | ||
@@ -24,7 +25,10 @@ void Options::parse( int argc, char *argv[] ) | |||
24 | " - Simple, Textual, Adventure Game Environment"); | 25 | " - Simple, Textual, Adventure Game Environment"); |
25 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + | 26 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + |
26 | " [options] <filename>\n"); | 27 | " [options] <filename>\n"); |
27 | opt.addOption( Bu::slot( this, &Options::version ), Bu::String("version"), Bu::String("Show the version info.") ); | 28 | opt.addOption( Bu::slot( this, &Options::version ), "version", |
29 | "Show full version info." ); | ||
30 | opt.addOption( Bu::slot( this, &Options::builtins ), "builtins", | ||
31 | "List available builtins." ); | ||
28 | opt.addHelpOption('h', "help"); | 32 | opt.addHelpOption('h', "help"); |
29 | opt.setNonOption( Bu::slot( this, &Options::nonOption ) ); | 33 | opt.setNonOption( Bu::slot( this, &Options::nonOption ) ); |
30 | opt.parse( argc, argv ); | 34 | opt.parse( argc, argv ); |
@@ -36,7 +40,21 @@ int Options::version( Bu::StrArray aArgs ) | |||
36 | << sio.nl << sio.nl; | 40 | << sio.nl << sio.nl; |
37 | sio << "Full version: " FULLVER << sio.nl; | 41 | sio << "Full version: " FULLVER << sio.nl; |
38 | sio << "Build date: " TIMEVER << sio.nl; | 42 | sio << "Build date: " TIMEVER << sio.nl; |
39 | // sio << "Commit id: " SHAVER << sio.nl; | 43 | sio << "Build id: " SHAVER << sio.nl; |
44 | sio << sio.nl; | ||
45 | exit( 0 ); | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | int Options::builtins( Bu::StrArray aArgs ) | ||
50 | { | ||
51 | sio << "Current builtin functions:" << sio.nl; | ||
52 | Game g; | ||
53 | const Game::FunctionHash &hFnc = g.getFunctionHash(); | ||
54 | for( Game::FunctionHash::const_iterator i = hFnc.begin(); i; i++ ) | ||
55 | { | ||
56 | sio << " - " << i.getKey() << sio.nl; | ||
57 | } | ||
40 | sio << sio.nl; | 58 | sio << sio.nl; |
41 | exit( 0 ); | 59 | exit( 0 ); |
42 | return 0; | 60 | return 0; |
diff --git a/src/options.h b/src/options.h index 09ad19a..5b3f413 100644 --- a/src/options.h +++ b/src/options.h | |||
@@ -19,6 +19,7 @@ public: | |||
19 | 19 | ||
20 | protected: | 20 | protected: |
21 | int version( Bu::Array<Bu::String> aArgs ); | 21 | int version( Bu::Array<Bu::String> aArgs ); |
22 | int builtins( Bu::Array<Bu::String> aArgs ); | ||
22 | int nonOption( Bu::Array<Bu::String> aArgs ); | 23 | int nonOption( Bu::Array<Bu::String> aArgs ); |
23 | }; | 24 | }; |
24 | 25 | ||